Style Guide CSS Guidlines
Print this Page
CSS Coding Guidelines

CSS is not a pretty language. While it is simple to get started with, it soon becomes problematic at any reasonable scale. There isn’t much we can do to change how CSS works, but we can make changes to the way we author and structure it. In working on large, long-running projects, with dozens of developers of differing specialities and abilities, it is important that we all work in a unified way in order to keep stylesheet maintainable, scalable, and to keep code transparent, sane and readable as well.

MySolidWorks Site Framework Structure

MySolidWorks site was initially built up with Boostrap 2 using the LESS CSS Preprocessor. CSS preprocessing is a method of extending the feature set of CSS by first writting the style sheets in a new extended language, then compiling the code to vanillar CSS so that it can be read by Web browsers. LESS is one of most notable of several CSS preprocessors like SASS.

Difference between LESS and SCSS

LESS was designed to be as close to CSS as possible, so the syntax is indentical to the current CSS code, and can be used right away with the existing code in dev. SASS was designed to both simplify and extend CSS, so things like curly braces were removed from syntax. But SASS also introduced a CSS-like syntax called SCSS (Sassy CSS) to migrating easier. Bootstrap 3 still uses LESS for styling, but also provides an official SASS port to SASS/SCSS.

Framework Upgrade and Moving from Less to SCSS

Now we are upgrading the framework from bootstrap 2 to 3, and also moving from LESS to SCSS in consideration of getting ready for furhter framework upgrade, since Bootstrap 4 will say goodbye to LESS.

OOCSS Methodology and Boostrap CSS

We learn that all common CSS methodologies are trying to separate content from structure by placing styles in reusable modular blocks of code. Among them, the OOCSS Framework is an methodology similar to Bootstrap Framework CSS for its rules of classing, subclassing and naming convention. This can be an appraoch to derive a standard of writing our CSS.

Codling Guidelines

Although separating frond-end from back-end is an ideal technique to develop web projects, MySolidWorks was not built in that way. Every developer has chance to touch CSS, creat new classes, edit and modify them at will without guidelines. Along with our website grows, our CSS gets messier. There is obviously a need for a better system and standard of writing CSS so as to keep code maintainable, easy to read and standard-based. Having good coding guidelines, when well followed, will:

One of the simplest forms of guidelines is a set of rules regarding syntax and formatting. Having a standard way of writing (literally writing) CSS means that code will always look and feel familiar to all members of the team.

Further, code that looks clean feels clean. It is a much nicer environment to work in, and prompts other team members to maintain the standard of cleanliness that they found. Ugly code sets a bad precedent.

Basic Syntax

Naming Covention for Class Selectors

To learn about more coding style for CSS and HTML, please use this Codestyle website as reference for best practice.